<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="关键字" prop="roleName">
        <el-input v-model="queryParams.informationName" placeholder="请输入关键字" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="场馆" prop="status">
        <el-select v-model="queryParams.status" placeholder="场馆选择" clearable filterable style="width: 240px">
          <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item label="商品类型" prop="status">
        <el-select v-model="queryParams.status" placeholder="商品类型" clearable style="width: 240px">
          <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="信息状态" clearable style="width: 240px">
          <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="转售状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="转售状态" clearable style="width: 240px">
          <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="止售区域" prop="status">
        <el-select v-model="queryParams.status" placeholder="止售区域" clearable style="width: 240px">
          <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="止售日期" prop="status"> </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['showroom:lot:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="queryParams.status == 0" type="success" plain size="mini" :disabled="single" @click="changeLotStatus" v-hasPermi="['showroom:lot:up']">一键上架</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="queryParams.status == 1" type="danger" plain size="mini" :disabled="multiple" @click="changeLotStatus" v-hasPermi="['showroom:lot:down']">一键下架</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-download" size="mini" @click="exportExcel" v-hasPermi="['order:resale:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="goodsList" stripe border>
      <el-table-column label="序号" type="index" width="60" />
      <el-table-column label="商品名称" prop="name" width="200" />
      <el-table-column label="商品编号" prop="goodsNo" width="150" />
      <el-table-column label="场馆名称" prop="venueInfo.name" width="150" />
      <el-table-column label="商品类型" prop="typeCode" width="200" />
      <el-table-column label="成本价(元)" prop="costPrice" width="120" />
      <el-table-column label="现金价格(元)" prop="cashPrice" width="120" />
      <el-table-column label="金积分价格" prop="goldPrice" width="120" />
      <el-table-column label="银积分价格" prop="silverPrice" width="120" />
      <el-table-column label="是否上架" prop="isPutaway" />
      <el-table-column label="转售状态" prop="title" width="120" />
      <el-table-column label="止售次数" prop="resellNum" width="120" />
      <el-table-column label="止售价" width="120" />
      <el-table-column label="缩略图" prop="imgMin" align="center" width="200">
        <template slot-scope="scope">
          <el-popover placement="top-start" title="" trigger="hover" v-if="scope.row.fileUrl">
            <img :src="scope.row.fileUrl" style="width: 150px; height: 150px" />
            <img slot="reference" :src="scope.row.fileUrl" style="width: 30px; height: 30px" />
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="大图" prop="minList" align="center" width="200">
        <template slot-scope="scope">
          <el-popover placement="top-start" title="" trigger="hover" v-if="scope.row.fileUrl">
            <img :src="scope.row.fileUrl" style="width: 150px; height: 150px" />
            <img slot="reference" :src="scope.row.fileUrl" style="width: 30px; height: 30px" />
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="排序" prop="orderNum" width="60" />
      <el-table-column label="创建时间" prop="createTime" width="180" />
      <el-table-column label="止售时间" prop="buyDate" width="180" />

      <el-table-column label="操作" fixed="right" align="center" width="180">
        <template slot-scope="scope" v-if="scope.row.roleId !== 1">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['showroom:lot:edit']">编辑</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click.stop="handleDelete(scope.row)" v-hasPermi="['showroom:lot:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <!-- 编辑竞价品 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="场馆名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入场馆名称" />
        </el-form-item>
        <el-form-item label="商品类型" prop="status">
          <el-select v-model="queryParams.status" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_status" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="商品名称" prop="name">
          <el-input v-model="form.name" placeholder="商品名称" />
        </el-form-item>
        <el-form-item label="商品编号" prop="name">
          <el-input v-model="form.name" placeholder="商品编号" />
        </el-form-item>
        <el-form-item label="成本价格(元)" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="现金价格(元)" prop="name">
          <el-input v-model="form.name" placeholder="请输入现金价格" />
        </el-form-item>
        <el-form-item label="金积分价格" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="银积分价格" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>

        <el-form-item label="是否上架" prop="venueType">
          <el-select v-model="queryParams.venueType" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="场馆" prop="venueType">
          <el-select v-model="queryParams.venueType" placeholder="兑换商品场馆归属" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="止售次数" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="缩略图" prop="imgUrl"> </el-form-item>
        <el-form-item label="大图" prop="imgUrl"> </el-form-item>
        <el-form-item label="排序" prop="dictSort">
          <el-input-number v-model="form.dictSort" controls-position="right" :min="0" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 新建竞价品 -->
    <el-dialog :title="title" :visible.sync="add_open" width="800px" append-to-body>
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="场馆名称" prop="name">
          <el-select v-model="queryParams.status" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_status" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="商品类型" prop="status">
          <el-select v-model="queryParams.status" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_status" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="购买赠送席位" prop="status">
          <el-select v-model="queryParams.status" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_lotGive_time" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="竞标价" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="投标额" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="中标价" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="未中标赠送席位(天)" prop="status">
          <el-select v-model="queryParams.status" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_lotGive_time" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="商品名称" prop="name">
          <el-input v-model="form.name" placeholder="商品名称" />
        </el-form-item>
        <el-form-item label="商品编号" prop="name">
          <el-input v-model="form.name" placeholder="商品编号" />
        </el-form-item>
        <el-form-item label="成本价格(元)" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="现金价格(元)" prop="name">
          <el-input v-model="form.name" placeholder="请输入现金价格" />
        </el-form-item>
        <el-form-item label="金积分价格" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="银积分价格" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>

        <el-form-item label="是否上架" prop="venueType">
          <el-select v-model="queryParams.venueType" placeholder="" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="场馆" prop="venueType">
          <el-select v-model="queryParams.venueType" placeholder="兑换商品场馆归属" clearable style="width: 240px">
            <el-option v-for="dict in dict.type.showroom_venue_type" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="止售次数" prop="name">
          <el-input v-model="form.name" placeholder="" />
        </el-form-item>
        <el-form-item label="缩略图" prop="imgUrl"> </el-form-item>
        <el-form-item label="大图" prop="imgUrl"> </el-form-item>
        <el-form-item label="排序" prop="dictSort">
          <el-input-number v-model="form.dictSort" controls-position="right" :min="0" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listGoodsInfo } from "@/api/showroom/goods";

export default {
  name: "Lot", //竞价品信息
  dicts: [
    "showroom_venue_status",
    "showroom_venue_type",
    "showroom_lotGive_time",
  ],
  data() {
    return {
      //上传的图片
      dialogImageUrl: "",
      dialogVisible: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 场馆信息列表数据
      goodsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //是否显示添加弹窗
      add_open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: this.global.pageSize,
        name: undefined,
        // type: undefined,
        status: 1, //0 停用 1 正常
      },

      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      listGoodsInfo(this.queryParams)
        .then((response) => {
          if (response.code == 200) {
            this.goodsList = response.data;
            this.total = response.total;
          }
          this.loading = false;
        })
        .catch((err) => {
          this.loading = false;
        });
    },

    /**一键上下架 */
    changeLotStatus() { },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 表单重置
    reset() {
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.add_open = true;
      this.title = "添加竞价品";
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.open = true;
      this.title = "编辑竞价品";
    },

    /** 提交按钮 */
    submitForm: function () {
      // console.log(this.$refs.childMethod.currentValue);
      // this.$refs["form"].validate((valid) => {});
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      this.$modal
        .confirm('是否确认删除角色编号为"' + roleIds + '"的数据项？')
        .then(function () {
          // return delRole(roleIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },

    /** 导出按钮操作 */
    exportExcel() {
      this.download(
        "system/dict/data/export",
        {
          ...this.queryParams,
        },
        `data_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style scoped>
</style>
